//
//  OrderListTableCell.m
//  didacar
//
//  Created by 度周末网络-王腾 on 15/12/25.
//  Copyright © 2015年 dzmmac. All rights reserved.
//

#import "OrderListTableCell.h"

@implementation OrderListTableCell

-(void)awakeFromNib{
    UIView *topLine = [CommoneTools createLineWithFrame:CGRectMake(0, 39, [UIScreen width], 0.45)];
    UIView *topLine1 = [CommoneTools createLineWithFrame:CGRectMake(0, 0, [UIScreen width], 0.45)];
    
    [self.topView addSubview:topLine1];
    
    [self.topView addSubview:topLine];
    
    UIView *bottomLine = [CommoneTools createLineWithFrame:CGRectMake(0, 0, [UIScreen width], 0.45)];
   UIView *bottomLine1 = [CommoneTools createLineWithFrame:CGRectMake(0, 39.5, [UIScreen width], 0.45)];
    [self.bottomView addSubview:bottomLine];
    [self.bottomView addSubview:bottomLine1];
}

-(void)setModel:(ResponseOrderListModel *)orderModel{
    if (orderModel == nil) {
        return;
    }
    
    self.time.text = orderModel.SendTime;
    
    // 订单类型
    [self setOrderTypeText:orderModel.TicketType];
    
    // 订单状态
    [self setOrderStatusText:orderModel.PayType];
    
    // 上车点
    [BaseTableViewCell setBusLineStartLocationString:orderModel.StartStation startStationType:orderModel.StartStationType label:self.start];
    
    // 下车点
    self.end.text = orderModel.EndStation;
    
    self.price.attributedText    = [self getPrice:orderModel.TicketPrice.stringValue orderStatus:orderModel.PayType];
    
    self.payPrice.attributedText = [self getPayPrice:orderModel.TicketPrice.stringValue];
    
    self.orderNum.text = [NSString stringWithFormat:@"订单号:%@",orderModel.TicketOrderNum];
    
    self.orderTime.text = [NSString stringWithFormat:@"下单时间:%@",orderModel.CreatTime];
    
    // 包含
    if (orderModel.IsRefund == 1) {
        self.info.hidden = NO;
    }else{
        self.info.hidden = YES;
    }
    
}

-(NSAttributedString *)getPrice:(NSString *)price orderStatus:(NSInteger)orderStatus{
    NSMutableArray *mutableString = [[NSMutableArray alloc ] init];
    
    if (orderStatus ==1) {
        [mutableString addObject:[MainInfoTitleFields getInstaceWithText:@"实付:" hexColor:GLOBLE_GRAY_COLOR_5_HEX fontSize:@"12"]];
    }else{
        [mutableString addObject:[MainInfoTitleFields getInstaceWithText:@"应付:" hexColor:GLOBLE_GRAY_COLOR_5_HEX fontSize:@"12"]];
    }
    
    [mutableString addObject:[MainInfoTitleFields getInstaceWithText:price hexColor:GLOBLE_ORANGE_COLOR_HEX fontSize:@"12"]];
    [mutableString addObject:[MainInfoTitleFields getInstaceWithText:@"元" hexColor:GLOBLE_ORANGE_COLOR_HEX fontSize:@"12"]];
    return [CommoneTools getAttributeString:mutableString];
}

-(NSAttributedString *)getPayPrice:(NSString *)price{
    NSMutableArray *mutableString = [[NSMutableArray alloc ] init];
 
    [mutableString addObject:[MainInfoTitleFields getInstaceWithText:price hexColor:GLOBLE_ORANGE_COLOR_HEX fontSize:@"20"]];
    [mutableString addObject:[MainInfoTitleFields getInstaceWithText:@"元" hexColor:GLOBLE_ORANGE_COLOR_HEX fontSize:@"17"]];
    return [CommoneTools getAttributeString:mutableString];
}

// 1-已支付，2-待支付，3-已取消
-(void)setOrderStatusText:(NSInteger)orderStatus{
    if (orderStatus == 1) {
        self.orderStatus.text = @"已支付";
    }else if (orderStatus == 2){
        self.orderStatus.text = @"待支付";
    }else if (orderStatus == 3){
        self.orderStatus.text = @"已取消";
    }
}

// 订单类型
-(void)setOrderTypeText:(NSInteger)orderType{
    if (orderType == 1) {
        self.orderType.text = @"班车";
    }else if (orderType == 2) {
        self.orderType.text = @"直通车";
    }
}

@end
